<?php

require_once(drupal_get_path('module','gc_filters').'/classes/proto/GcBaseFilter.class.php');

class GcPriceSortFilter extends GcBaseFilter {
    
  const filterPathId = 'gcfPriceSort';
  const filterDatabaseTableName    = 'uc_products';
  const filterDatabaseColumnName   = 'sell_price';
  
  private $_filterValue;
  

  public function getFilterDatabaseQuery($bootstrap) {
    $responce = '';
    
    switch($bootstrap) {
      case 'order by':
        $responce =  $this->prepareFilterOrderQuery();
      break;
      case 'join':
        $responce = $this->getFilterTableName();
      break;
        
    };
    return $responce;
  }

  protected function getFilterValue() {
    return $_GET[self::filterPathId];
  }
  
  protected function getFilterTableName() {
    return self::filterDatabaseTableName;
  }
  
  protected function prepareFilterOrderQuery() {
    
    $columnName = self::filterDatabaseColumnName;
    
    $query = '';     
    $query .= $columnName." ".$this->getFilterValue()." ";
    return $query;
  
  }
  
  public function isActive() {
    if(isset($_GET[self::filterPathId]) && $_GET[self::filterPathId]) {
      return  true;
    } else {
      return false;
    }
  }
}